package com.lzclass.servlet.whyservlet;

import com.alibaba.fastjson.JSON;

import com.lzclass.service.whyservice.ArcitleService;
import com.lzclass.util.ServiceUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//模糊查标题
//需要参数：atctitle
//返回参数:List<Article,List<Article_Type>, List<BackMessage>>
@WebServlet("/allfindBytitle")
public class ArcitleByTitleServlet extends HttpServlet {
    private ArcitleService arcitleService = (ArcitleService) ServiceUtil.getService("arcitleServiceImpl");
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String atctitle = req.getParameter("atctitle");


        resp.setContentType("text/html;charset=UTF-8");
        resp.getWriter().write(JSON.toJSONString(arcitleService.allfindArcitleByTitle(atctitle)));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
